home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
CpuMultiplexor.h,v
< prev
next >
Wrap
Text File
|
1989-03-22
|
6KB
|
309 lines
head 3.3;
branch ;
access ;
symbols ;
locks grunwald:3.3; strict;
comment @ * @;
3.3
date 89.03.22.22.13.14; author grunwald; state Exp;
branches ;
next 3.2;
3.2
date 89.02.20.15.34.01; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.49.36; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.11.02.13.40.15; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.10.30.13.05.36; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.3
log
@before subclass
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
#ifndef CpuMultiplexor_h
#define CpuMultiplexor_h
#include <Config.h>
#include <HardwareContext.h>
#include <CpuMuxExceptions.h>
#include <SpinLock.h>
//
// Define the abstractions for per UNIX process resources.
//
#include <ThreadContainer.h>
class Thread;
class ReserveByException;
class AwesimeHeap;
class SpinLock;
class SpinFetchAndOp;
class CpuMultiplexor;
//
// Filled in by the single original UNIX process. This value may
// change during execution
//
extern int CpuMultiplexors;
extern CpuMultiplexor *ThisCpu;
extern int CpuMuxDebugFlag;
extern SpinLock CpuCerrLock;
class CpuMultiplexor {
protected:
Thread *currentThread;
HardwareContext systemContext;
ThreadContainer *myCurrentEvents;
SpinLock *myCurrentEventsLock;
int *myCurrentEventsCounter;
SpinFetchAndOp *globalCurrentEventsCounter;
int iYam; // I yam what I yam
int pid; // ...except to UNIX
int oldGeneration; // placed here to avoid optimizer screwups
char nameSpace[128];
char *pNameTemplate;
char *pName;
int *terminated;
int enabled;
Thread *remove();
//
// Constructors of this class and all subclasses should call their
// own allocateLocalEventStructures, because constructors automatically
// chain the calls.
//
// Use AllocateEventStructures when allocating resources for a CPU and
// you're not in the constructor. Use deallocateEventStructures for
// removing those resources. These routines should call subclass
// instances of the same names.
//
void allocateLocalEventStructures(int,int);
virtual void allocateEventStructures(int,int);
virtual void deallocateEventStructures();
//
// Primarily provided so subclasses, e.g. SimulationMultiplexor,
// can efficiently add threads without a lot of locking.
//
void addUnlocked(Thread *);
void addToAnother(int, Thread *);
//
// Exception handlers.
//
friend class ExceptionReserve;
friend class ExceptionTerminate;
friend class ExceptionReschedule;
friend class ExceptionIveSuspended;
friend class ExceptionEnrollDismissCpu;
ExceptionClass *raisedBy;
ExceptionReserve reserveException;
ExceptionTerminate terminateException;
ExceptionReschedule rescheduleException;
ExceptionIveSuspended iveSuspendedException;
ExceptionEnrollDismissCpu enrollDismissCpuException;
//
// Public interfaces for exceptions
//
public:
void raise(ExceptionClass *);
void reserveByException( ReserveByException * );
void threadTerminateException( void ** );
void flick();
public:
CpuMultiplexor(int debug = 0);
virtual ~CpuMultiplexor();
virtual void fireItUp(int Cpus = 1, unsigned shared = (4196 * 500));
virtual void warmThePot(int);
virtual void stirItAround();
virtual void coolItDown();
virtual void terminateAll();
virtual void enrollCpu();
virtual void dismissCpu();
virtual void add(Thread *);
Thread * CurrentThread();
void debug(int newdebug);
int debug();
char *name();
int cpuId();
};
inline int CpuMultiplexor::cpuId()
{
return( iYam );
}
inline char *
CpuMultiplexor::name()
{
return(pName);
}
inline Thread *
CpuMultiplexor::CurrentThread()
{
return( currentThread );
}
inline void
CpuMultiplexor::addUnlocked(Thread *who)
{
//
// Add them to the list of current events
//
myCurrentEvents -> add( who );
}
//
// Expansions for exception handling
//
#include <Thread.h>
inline void
CpuMultiplexor::reserveByException( ReserveByException *sem )
{
reserveException.reserve(sem);
raise( &reserveException );
}
inline void
CpuMultiplexor::threadTerminateException( void **killMe )
{
terminateException.terminate( killMe );
raise( &terminateException );
}
inline void
CpuMultiplexor::flick()
{
rescheduleException.cpu(-1);
currentThread -> cpuAffinity = -1;
raise( &rescheduleException );
}
inline Thread *
CurrentThread()
{
return( ThisCpu -> CurrentThread() );
}
inline void
CheckCurrentStack()
{
CurrentThread() -> checkStack();
}
//
// These are things the user needs to define
//
extern ThreadContainer *AllocateHardwareCurrentEventsStructure();
#endif /* CpuMultiplexor_h */
@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@d10 4
a13 4
#include "Config.h"
#include "HardwareContext.h"
#include "CpuMuxExceptions.h"
#include "SpinLock.h"
d19 1
a19 1
#include "ThreadContainer.h"
d169 1
a169 1
#include "Thread.h"
d196 6
@
3.1
log
@Steay version
@
text
@@
1.2
log
@Before using SpinEvents for global coordination
@
text
@d56 1
d63 12
a74 1
virtual void allocateEventStructures(int);
d76 5
d92 1
d99 1
d188 1
@
1.1
log
@Initial revision
@
text
@d53 2
@